﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace TMIS
{
    public partial class frmInstructionOpinion : frmCommon
    {
        private Guid guid;
        private BLL.InstructionOpinion bll = new BLL.InstructionOpinion();
        public frmInstructionOpinion()
        {
            InitializeComponent();
        }
        public frmInstructionOpinion(Guid guid)
        {
            this.guid = guid;
            InitializeComponent();
            this.FillComponent();
        }
        /// <summary>
        /// 窗体控件数据初始化
        /// </summary>
        private void FillComponent()
        {
            Model.InstructionOpinion ins = bll.Get(guid);
            txtAttitude.Text = ins.Attitude.ToString();
            txtSurvey.Text = ins.Survey.ToString();
            txtDesign.Text = ins.Design.ToString();
            txtAbility.Text = ins.Ability.ToString();
            txtQuality.Text = ins.Quality.ToString();
            txtInnovation.Text = ins.Innovation.ToString();
            txtTotal.Text = ins.TotalScore.ToString();
            this.Priview();
        }
        public override void Save()
        {
            txtTotal.Text = (Convert.ToInt16(txtAttitude.Text) + Convert.ToInt16(txtSurvey.Text) + Convert.ToInt16(txtDesign.Text) + Convert.ToInt16(txtAbility.Text) + Convert.ToInt16(txtQuality.Text) + Convert.ToInt16(txtInnovation.Text)).ToString();
            Model.InstructionOpinion instrucionopinion = new Model.InstructionOpinion()
            {
                ID = this.guid,
                Attitude=Convert.ToInt16(txtAttitude.Text),
                Survey=Convert.ToInt16(txtSurvey.Text),
                Design=Convert.ToInt16(txtDesign.Text),
                Ability = Convert.ToInt16(txtAbility.Text),
                Quality = Convert.ToInt16(txtQuality.Text),
                Innovation = Convert.ToInt16(txtInnovation.Text),
                TotalScore=Convert.ToInt16(txtTotal.Text)
            };
            bll.Update(instrucionopinion);
        }

        public override void Priview()
        {
            this.instructionOpinionTableAdapter.FillByStudnetID(this.reportDS.InstructionOpinion, guid);
            this.reportViewer.RefreshReport();
        }
    }
}
